<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>18-移除事件监听</title>
</head>
<body>
    <button class="l2">移除L2事件监听</button>
    <button class="l0">移除L0事件监听</button>
   
    <script>
        // 需求：按钮就点击一次，然后移除点击事件

        // 1. l2事件监听
        const l2 = document.querySelector('.l2')

        l2.addEventListener('click',fn)

        function fn(){
            alert('我点击了')
            // 移除事件监听
            l2.removeEventListener('click',fn)
        }

        // 2. l0事件监听
        const l0 = document.querySelector('.l0')
        l0.onclick = function () {
            alert('我点击了')
            l0.onclick = null
        }


    </script>
</body>
</html>